/**
 *  Version:  $Revision: 1 $
 */

package gemini.basic.exception;

import java.io.Serializable;
import java.text.MessageFormat;

/**
 * Base class for a client exception.
 *
 */
public class GmnClientException extends Exception implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * A special flag indicating that this exception has been handled by a handler in GUI layer and <b>should NOT</b>
     * propagate to another handler.
     */
    private boolean cancelBubble;

    /**
     * Default constructor. Subclasses must override this constructor because it's the requirement of GWT.
     */
    public GmnClientException() {
        super();
    }

    /**
     * Constructs this exception with a message and a cause error.
     *
     * @param message
     * @param cause
     */
    public GmnClientException(final String message, final Throwable cause,
            final String... messageParameters) {
        super(MessageFormat.format(message, (Object[]) messageParameters), cause);
    }

    /**
     * Constructs this exception with a message.
     *
     * @param message
     */
    public GmnClientException(final String message, final String... messageParameters) {
        super(MessageFormat.format(message, (Object[]) messageParameters));
    }

    /**
     * Constructs this exception with a cause error.
     *
     * @param cause
     */
    public GmnClientException(final Throwable cause) {
        super(cause);
    }

    /**
     * Returns current value of cancelBubble.
     *
     * @return the cancelBubble.
     */
    public boolean isCancelBubble() {
        return cancelBubble;
    }

    /**
     * Sets new value for cancelBubble.
     *
     * @param cancelBubble
     *            the cancelBubble to set.
     */
    public void setCancelBubble(boolean cancelBubble) {
        this.cancelBubble = cancelBubble;
    }
}
